package net.hn.hnms.biz.cockpit.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import net.hn.hnms.biz.cockpit.domain.VideoConfig;
import net.hn.hnms.biz.cockpit.service.IVideoConfigService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "页面展示视频管理", tags = {"页面展示视频管理"})
@RestController
@RequestMapping("/cockpit/video")
@RequiredArgsConstructor
public class VideoConfigController {

    private final IVideoConfigService videoConfigService;

    @ApiOperation("视频配置列表")
    @GetMapping("/list")
    @AutoSetMineCode
    public R<List<VideoConfig>> videoConfigList(String mineCode) {
        LambdaQueryWrapper<VideoConfig> lambdaQueryWrapper = new LambdaQueryWrapper<VideoConfig>().eq(VideoConfig::getMineCode, mineCode);
        return R.ok(videoConfigService.list(lambdaQueryWrapper));
    }

    @ApiOperation("新增视频配置")
    @PostMapping("/add")
    public R<?> addVideoConfig(@RequestBody VideoConfig videoConfig) {
        videoConfigService.save(videoConfig);
        return R.ok("保存成功");
    }

    @ApiOperation("删除视频配置")
    @DeleteMapping("/delete")
    public R<?> deleteVideoConfig(String id) {
        videoConfigService.removeById(id);
        return R.ok("删除成功");
    }

    @ApiOperation("修改视频配置")
    @PutMapping("/update")
    public R<?> updateVideoConfig(@RequestBody VideoConfig videoConfig) {
        videoConfigService.updateById(videoConfig);
        return R.ok("修改成功");
    }

}
